#!/usr/bin/env python
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSES folder in the root directory of this source tree.
# SPDX-License-Identifier: MIT
# @package _group_

type: lightfield

render:
  type: lightfield

param:
  n_dims: 6
  fn: identity


### EMBEDDING ###
embedding:
  type: ray_point

  embeddings:
    ray_prediction_0:
      type: ray_prediction

      # Parameterization
      params:
        ray:
          start: 0
          end: 6

          param:
            n_dims: 6
            fn: pluecker
            direction_multiplier: 1.0
            moment_multiplier: 1.0

          pe:
            type: windowed
            freq_multiplier: 2.0
            n_freqs: 1
            wait_iters: 0
            max_freq_epoch: 0
            exclude_identity: False

      # Net
      net:
        type: base
        group: embedding_impl

        depth: 6
        hidden_channels: 256
        skips: [3]

      # Outputs
      z_channels: 32

      outputs:
        z_vals:
          channels: 4

        sigma:
          channels: 1

          activation:
            type: ease_value
            start_value: 1.0
            window_epochs: 3
            wait_epochs: 0

            activation:
              type: sigmoid
              shift: 4.0

        point_sigma:
          channels: 1

          activation:
            type: ease_value
            start_value: 1.0
            window_epochs: 3
            wait_epochs: 1

            activation:
              type: sigmoid
              shift: 4.0

        point_offset:
          channels: 3

          activation:
            type: tanh
            outer_fac: 0.125

        color_scale:
          channels: 3

          activation:
            type: ease_value
            start_value: 0.0
            window_epochs: 0
            wait_epochs: 0

            activation:
              type: identity
              shift: 0.0
              inner_fac: 1.0
              outer_fac: 1.0

        color_shift:
          channels: 3

          activation:
            type: ease_value
            start_value: 0.0
            window_epochs: 0
            wait_epochs: 0

            activation:
              type: identity
              shift: 0.0
              inner_fac: 1.0
              outer_fac: 1.0

    ray_intersect_0:
      type: ray_intersect

      # Intersect
      z_channels: 32

      intersect:
        #type: cylinder
        type: sphere

        sort: True
        outward_facing: False
        use_disparity: False
        max_axis: False

        use_sigma: True

        out_points: raw_points
        out_distance: raw_distance

        use_dataset_bounds: True
        origin_scale_factor: 0.0

        contract:
          type: mipnerf
          contract_samples: True
          use_dataset_bounds: True

        activation:
          type: identity
          fac: 0.5

    add_point_outputs_0:
      type: add_point_outputs
      extra_outputs: ['viewdirs']

    extract_fields:
      type: extract_fields
      fields: ['points', 'distances', 'viewdirs', 'weights', 'color_scale', 'color_shift']


### COLOR ###
color:
  type: base

  net:
    type: tensor_vm_split_no_sample

    # Scene hyper-params
    white_bg: 0
    black_bg: 0

    # Density activation
    fea2denseAct: relu
    distance_scale: 16.0
    density_shift: 0.0

    # Grid bounds
    aabb: [[-2.0, -2.0, -2.0], [2.0, 2.0, 2.0]]

    # Grid size and upsampling
    N_voxel_init: 3375000
    N_voxel_final: 216000000

    upsamp_list: [4000,6000,8000,10000,12000]
    lr_upsample_reset: True

    # Thresholding
    update_AlphaMask_list: [4000,8000]
    rm_weight_mask_thre: 0
    alpha_mask_thre: 1e-3

    # Tensor sizes
    n_lamb_sigma: [8,4,4]
    n_lamb_sh: [8,4,4]

    ## Shading
    shadingMode: RGB
    data_dim_color: 3
